// 格式化验证条件
export function formatValidateRules (rules) {
  const reg = /^\/(.+)\/(.*)/
  if (!(rules instanceof Array)) {
    return []
  }
  return rules.map(rule => {
    if (typeof rule.pattern === 'string') {
      try {
        const res = rule.pattern.match(reg)
        const args = res.slice(1)
        rule.pattern = new RegExp(...args)
      } catch (e) {
        console.error(e)
      }
    }
    return rule
  })
}
